package com.itheima.service.mongo.impl;

import com.itheima.domain.mongo.ResultSelect;
import com.itheima.service.mongo.ResultSelectService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;

@DubboService
public class ResultSelectServiceImpl implements ResultSelectService {
    @Autowired
    private MongoTemplate mongoTemplate;

    //根据得分查询
    @Override
    public ResultSelect findByScore(Integer score) {
        //构建条件
        Query query = new Query(Criteria.where("ge").lte(score).and("lt").gt(score));
        //查询
        return mongoTemplate.findOne(query,ResultSelect.class);
    }
}
